/**
 * Created by Adam on 2017/5/19.
 */

const loginInfo = (state = {isLoggedIn: false, redirectUrl: '/users/All', errorMsg: ''}, action) => {
    switch (action.type) {
        case 'LOGIN_SUCCESS':
            return Object.assign({}, state, {isLoggedIn: true, errorMsg: ''})
        case 'LOGIN_FAILED':
            return Object.assign({}, state, {isLoggedIn: false, errorMsg: action.errorMsg})
        case 'LOG_OUT':
            return Object.assign({}, state, {isLoggedIn: false, errorMsg: ''})
        case 'SET_REDIRECT_URL':
            return Object.assign({}, state, {redirectUrl: action.redirectUrl})
        default:
            return state
    }
}

export default loginInfo